/*   1:    */ package org.jetbrains.debugger;
/*   2:    */ 
/*   3:    */

import com.intellij.openapi.util.ActionCallback;
import com.intellij.util.Consumer;
import com.intellij.xdebugger.XDebuggerBundle;
import com.intellij.xdebugger.frame.XCompositeNode;
import com.intellij.xdebugger.frame.XValueChildrenList;
import com.intellij.xdebugger.frame.XValueGroup;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */ 
/*  14:    */ public class ScopeVariablesGroup
/*  15:    */   extends XValueGroup
/*  16:    */ {
/*  17:    */   private final Scope a;
/*  18:    */   private final VariableContext b;
/*  19:    */   private final CallFrame c;
/*  20:    */   
/*  21:    */   public ScopeVariablesGroup(@NotNull Scope paramScope, @NotNull VariableContext paramVariableContext, @Nullable CallFrame paramCallFrame)
/*  22:    */   {
/*  23: 21 */     super(a(paramScope));
/*  24:    */     
/*  25: 23 */     this.a = paramScope;
/*  26: 25 */     if ((paramCallFrame == null) || (paramScope.getType() == Scope.Type.LIBRARY)) {
/*  27: 27 */       this.b = new ParentlessVariableContext(paramVariableContext, paramScope, paramScope.getType() == Scope.Type.GLOBAL);
/*  28:    */     } else {
/*  29: 30 */       this.b = new VariableContextWrapper(paramVariableContext, paramScope);
/*  30:    */     }
/*  31: 33 */     this.c = (paramScope.getType() == Scope.Type.LOCAL ? paramCallFrame : null);
/*  32:    */   }
/*  33:    */   
/*  34:    */   public static void createAndAddScopeList(@NotNull XCompositeNode paramXCompositeNode, @NotNull List<Scope> paramList, @NotNull VariableContext paramVariableContext, @Nullable CallFrame paramCallFrame)
/*  35:    */   {
/*  36: 37 */     if (paramXCompositeNode == null) {
/*  37: 37 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/debugger/ScopeVariablesGroup", "createAndAddScopeList" }));
/*  38:    */     }
/*  39: 37 */     if (paramList == null) {
/*  40: 37 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "1", "org/jetbrains/debugger/ScopeVariablesGroup", "createAndAddScopeList" }));
/*  41:    */     }
/*  42: 37 */     if (paramVariableContext == null) {
/*  43: 37 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "2", "org/jetbrains/debugger/ScopeVariablesGroup", "createAndAddScopeList" }));
/*  44:    */     }
/*  45: 37 */     XValueChildrenList localXValueChildrenList = new XValueChildrenList(paramList.size());
/*  46: 38 */     for (Scope localScope : paramList) {
/*  47: 39 */       localXValueChildrenList.addTopGroup(new ScopeVariablesGroup(localScope, paramVariableContext, paramCallFrame));
/*  48:    */     }
/*  49: 41 */     paramXCompositeNode.addChildren(localXValueChildrenList, true);
/*  50:    */   }
/*  51:    */   
/*  52:    */   private static String a(@NotNull Scope paramScope)
/*  53:    */   {
/*  54: 45 */     if (paramScope == null) {
/*  55: 45 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/debugger/ScopeVariablesGroup", "createScopeNodeName" }));
/*  56:    */     }
/*  57: 45 */     switch (2.$SwitchMap$org$jetbrains$debugger$Scope$Type[paramScope.getType().ordinal()])
/*  58:    */     {
/*  59:    */     case 1: 
/*  60: 47 */       return XDebuggerBundle.message("scope.global", new Object[0]);
/*  61:    */     case 2: 
/*  62: 49 */       return XDebuggerBundle.message("scope.local", new Object[0]);
/*  63:    */     case 3: 
/*  64: 51 */       return XDebuggerBundle.message("scope.with", new Object[0]);
/*  65:    */     case 4: 
/*  66: 53 */       return XDebuggerBundle.message("scope.closure", new Object[0]);
/*  67:    */     case 5: 
/*  68: 55 */       return XDebuggerBundle.message("scope.catch", new Object[0]);
/*  69:    */     case 6: 
/*  70: 57 */       return XDebuggerBundle.message("scope.library", new Object[0]);
/*  71:    */     case 7: 
/*  72: 59 */       return XDebuggerBundle.message("scope.instance", new Object[0]);
/*  73:    */     case 8: 
/*  74: 61 */       return XDebuggerBundle.message("scope.class", new Object[0]);
/*  75:    */     case 9: 
/*  76: 63 */       return XDebuggerBundle.message("scope.unknown", new Object[0]);
/*  77:    */     }
/*  78: 65 */     throw new IllegalArgumentException(paramScope.getType().name());
/*  79:    */   }
/*  80:    */   
/*  81:    */   public boolean isAutoExpand()
/*  82:    */   {
/*  83: 71 */     return (this.a.getType() == Scope.Type.LOCAL) || (this.a.getType() == Scope.Type.CATCH);
/*  84:    */   }
/*  85:    */   
/*  86:    */   @Nullable
/*  87:    */   public String getComment()
/*  88:    */   {
/*  89: 77 */     String str = this.a.getDescription();
/*  90: 78 */     return "Object".equals(str) ? null : str;
/*  91:    */   }
/*  92:    */   
/*  93:    */   public void computeChildren(@NotNull final XCompositeNode paramXCompositeNode)
/*  94:    */   {
/*  95: 83 */     if (paramXCompositeNode == null) {
/*  96: 83 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/debugger/ScopeVariablesGroup", "computeChildren" }));
/*  97:    */     }
/*  98: 83 */     ActionCallback localActionCallback = this.c == null ? null : new ActionCallback().doWhenDone(new Runnable()
/*  99:    */     {
/* 100:    */       public void run()
/* 101:    */       {
/* 102: 86 */         if (paramXCompositeNode.isObsolete()) {
/* 103: 87 */           return;
/* 104:    */         }
/* 105: 90 */         ScopeVariablesGroup.this.c.getReceiverVariable().doWhenDone(new Consumer()
/* 106:    */         {
/* 107:    */           public void consume(Variable paramAnonymous2Variable)
/* 108:    */           {
/* 109: 93 */             if (!ScopeVariablesGroup.1.this.val$node.isObsolete()) {
/* 110: 94 */               ScopeVariablesGroup.1.this.val$node.addChildren(paramAnonymous2Variable == null ? XValueChildrenList.EMPTY : XValueChildrenList.singleton("this", new VariableView(paramAnonymous2Variable, ScopeVariablesGroup.this.b)), true);
/* 111:    */             }
/* 112:    */           }
/* 113: 94 */         }).doWhenRejected(new Consumer()
/* 114:    */         {
/* 115:    */           public void consume(@Nullable String paramAnonymous2String)
/* 116:    */           {
/* 117:100 */             if (!ScopeVariablesGroup.1.this.val$node.isObsolete()) {
/* 118:101 */               ScopeVariablesGroup.1.this.val$node.addChildren(XValueChildrenList.EMPTY, true);
/* 119:    */             }
/* 120:    */           }
/* 121:    */         });
/* 122:    */       }
/* 123:106 */     });
/* 124:107 */     Variables.processScopeVariables(this.a, paramXCompositeNode, this.b, localActionCallback);
/* 125:    */   }
/* 126:    */   
/* 127:    */   private static final class ParentlessVariableContext
/* 128:    */     extends VariableContextWrapper
/* 129:    */   {
/* 130:    */     private final boolean c;
/* 131:    */     
/* 132:    */     public ParentlessVariableContext(@NotNull VariableContext paramVariableContext, @NotNull Scope paramScope, boolean paramBoolean)
/* 133:    */     {
/* 134:114 */       super(paramScope);
/* 135:    */       
/* 136:116 */       this.c = paramBoolean;
/* 137:    */     }
/* 138:    */     
/* 139:    */     public boolean watchableAsEvaluationExpression()
/* 140:    */     {
/* 141:121 */       return this.c;
/* 142:    */     }
/* 143:    */     
/* 144:    */     @Nullable
/* 145:    */     public VariableContext getParent()
/* 146:    */     {
/* 147:127 */       return null;
/* 148:    */     }
/* 149:    */   }
/* 150:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.debugger.ScopeVariablesGroup

 * JD-Core Version:    0.7.0.1

 */